<!DOCTYPE html>
<html>
  <head>
  	<#include "lib/lib.html" />
    <title>交易数据汇总</title>
	
  <meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-stand">
	<meta name="force-rendering" content="webkit">
	<meta http-equiv="x-ua-compatible" content="IE=11,10,9" >
	<link rel="stylesheet" href="../../public/css/normal.css" />
	<link rel="stylesheet" href="../../public/css/sjtj.css" />
  </head>
  
  <body>
    <nav class="breadcrumb">
        <i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
        交易管理<span class="c-gray en">&gt;</span> 交易数据汇总 <a
          class="btn btn-success radius r mr-20"
          style="line-height: 1.6em; margin-top: 3px"
          href="javascript:location.replace(location.href);" title="刷新"> <i
          class="Hui-iconfont">&#xe68f;</i></a>
    </nav>

    <div class="pd-20">      
      <div class="panel panel-default">
        <div class="panel-header" style="height: 30px;">
          <div style="float: left;font-size: 15px;">条件筛选</div>
          <div style="float: right;">
            <button class="layui-btn layui-btn-small surebtn2" type="button">
              <i class="layui-icon" style="line-height:12px;">&#xe615;</i>搜索
            </button>
          </div>
        </div>
        <div class="panel-body">
          <div class="tabChange">

            <div style="float:left;" class="layui-btn-group">
              <button class="layui-btn count actives today" day="1">
                <i class="layui-icon" style="line-height: 12px;">&#xe62c;</i>今日统计
              </button>
              <button class="layui-btn count yestoday" day="2">
                <i class="layui-icon" style="line-height: 12px;">&#xe62c;</i>昨日统计
              </button>
              <button class="layui-btn count last7" day="3">
                <i class="layui-icon" style="line-height: 12px;">&#xe62c;</i>前七天统计
              </button>
              <button class="layui-btn count last30" day="4">
                <i class="layui-icon" style="line-height: 12px;">&#xe62c;</i>前30天统计
              </button>
            </div>




            <!-- <ul>
              <li class=" " day="1">今日统计</li>
              <li class="yestoday" day="2">昨日统计</li>
              <li class="last7" day="3">前七天统计</li>
              <li class='last30' day="4">前30天统计</li>
            </ul> -->
            <div class="data fr">
              <label>选择日期：</label>
              <input placeholder="开始时间"
                  name="createTimeBegin" type="text"
                  value="${map.createTimeBegin!}"
                  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 00:00:00',maxDate:'#F{$dp.$D(\'logmax\')}'})"
                  id="logmin" class="input-text Wdate data1" style="width:170px;">
              <!-- <input type="text" class="dateShow begin input-text size-M data1" data-required id="begin" placeholder="请选择开始时间" style="width:150px;" > -->
              <span class="date-line">&nbsp;--&nbsp;</span>
              <input type="text" placeholder="结束时间"
                  name="createTimeEnd" value="${map.createTimeEnd!}"
                  onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',startDate:'%y-%M-%d 23:59:59',minDate:'#F{$dp.$D(\'logmin\')}'})"
                  id="logmax" class="input-text Wdate data2" style="width:170px;">
              <!-- <input type="text" class="dateShow end input-text size-M data2" data-required id="end" placeholder="请选择结束时间" style="width:150px;" > -->
            </div>
            <div class="line1" style="">
              <!-- 选择渠道商 -->
              <div class="chooseChannel">
                <label>来源渠道:</label>
                <select name="channelId" id="channelId" onchange="showCompany()">
                  <option value="">全部</option>
                  <#if payv2ChannelList?? && payv2ChannelList?size gt 0>
                  <#list payv2ChannelList as dl >
                    <option value="${dl.id}">${dl.channelName}</option>
                  </#list>
                  </#if>
                </select>
              </div>
              <!-- 选择商户 -->
              <div class="chooseCompany">
                <label>来源商户:</label>
                <select name="companyId" id="companyId" onchange="getAppsPayWays()">
                  <option value="">全部</option>
                  <#if companyList?? && companyList?size gt 0>
                  <#list companyList as dl >
                    <option value="${dl.id}">${dl.companyName}</option>
                  </#list>
                  </#if>
                </select>
              </div>
              
            </div>
            <div class="line2" style="">
              <div class="choosePayWay">
                <label>支付平台:</label>
                <select name="payWayId" id="payWayId" onchange="getPayWayList()">
                  <option value="">全部</option>
                  <#if payWayList?? && payWayList?size gt 0>
                  <#list payWayList as dl >
                    <option value="${dl.id}">${dl.wayName}</option>
                  </#list>
                  </#if>
                </select>
              </div>
               <#if switchType==2>
	              <div class="choosePayWayRate">
	                <label>支付通道</label>
	                <select name="rateId" id="rateId">
	                 <option value="">全部</option>
	                  <#if payWayRateList?? && payWayRateList?size gt 0>
	                  <#list payWayRateList as dl >
	                    <option value="${dl.id}">${dl.rateName}</option>
	                  </#list>
	                  </#if>
	                </select>
	              </div>
	            </#if>  
            </div>
          </div>
        </div>
      </div>

      <div class="panel panel-default mt-20">
        <div class="panel-header" style="height: 25px;">
          <div style="font-size: 15px;float: left;">关键数据指标</div>
        </div>
        <div class="panel-body">
          <!--关键指标-->
          <div class="index" style="margin: 20px 0 0 0 ;">
            <!-- <div class="index-title">
              <i></i>
              <span>关键数据指标</span>
            </div> -->
            <div class="index-content">
              <div class="index-1">
                <div class="index-1-title">支付成功金额(元)/笔数</div>
                <div class="index-1-data allmoney"></div>
                <div class="index-1-data allcount"></div>
              </div>
              <div class="index-2">
                <div class="index-1-title">未支付金额(元)/笔数</div>
                <div class="index-1-data allmoney"></div>
                <div class="index-1-data allcount"></div>
              </div>
              <div class="index-3">
                <div class="index-1-title">退款金额(元)/笔数</div>
                <div class="index-1-data allmoney"></div>
                <div class="index-1-data allcount"></div>
              </div>
              <div class="index-4">
                <div class="index-1-title">支付成功率(%)</div>
                <div class="index-1-data"></div>
              </div>
              <div class="index-5">
                <div class="index-1-title">交易净额(元)</div>
                <div class="index-1-data"></div>
              </div>
              <div class="index-6">
                <div class="index-1-title">商户交易手续费(元)</div>
                <div class="index-1-data"></div>
              </div>
              <div class="index-7">
                <div class="index-1-title">商户手续费利润(元)</div>
                <div class="index-1-data"></div>
              </div>
            </div>
          </div>
        </div>
      </div>
      
      <div class="panel panel-default mt-20">
        <div class="panel-header" style="height: 25px;">
          <div style="float: left;font-size: 15px;">交易时刻趋势图</div>
        </div>
        <div class="panel-body">

          <!--关键指标详解-->
          <div class="index-detail" style="margin:20px 0 0 0 ;">
            <!-- <div class="index-title">
              <i></i>
              <span>交易时刻趋势图</span>
            </div> -->
           
            <div id="main" style="width: 100%;height:400px;"></div>
          </div>



        </div>
      </div>
    </div>
    
    <style type="text/css">
      .tabChange {height:164px;}
      .line1 , .line2 {min-width: 1300px; height: 43px; margin-top: 17px; float: left;}
      .chooseChannel , .chooseCompany ,.choose,.choosePayWay,.choosePayWayRate{min-width: 280px; line-height: 0px; float: left; margin: 0 15px;}
      .data {width: 38%; margin-right: 45px;}
      .index-1 .allcount , .index-2 .allcount , .index-3 .allcount {margin-top: -5px;font-size: 30px;}
      .index-1 .allmoney , .index-2 .allmoney , .index-3 .allmoney {margin-top: 12px;font-size: 30px;}
      .index-4 .index-1-data , .index-5 .index-1-data , .index-6 .index-1-data , .index-7 .index-1-data{margin-top: 12px;}
    </style>	
  </body>
  
<script type="text/javascript" src="../../public/js/echarts.min.js"></script>
<script type="text/javascript" src="../../public/js/data.js"></script>
<script type="text/javascript">
  var isChange = 0; 
  $(document).ready(function() {
    $('select').searchableSelect();
    isChange++;
  })
  // 查询渠道商的商户
  function showCompany(){
      var channelId = $("#channelId").val();      
      if(isChange == 0){
        return;
      }else{
        $("#companyId").empty();
        $("#companyId").append('<option value="">全部</option>');
        $("#rateId").empty();
        $("#rateId").append('<option value="">全部</option>');
        $.ajax({
          type:"get",
          url:"${basePath}/Payv2CompanyMoneyClear/showCompany.do?channelId="+channelId,
          async:true,
          success:function(data){
            if(!!data&&data.resultCode==200){
              
              var list = data.Data,
              str="";
              for(var i=0;i<list.length;i++){
                str+='<option value="'+list[i].id+'">'+list[i].companyName+'</option>';
              }
              $("#companyId").append(str);
              $(".chooseCompany .searchable-select").remove();
              $('#companyId').searchableSelect();
            }else{
              alert(data.message);
            }
          }
        });
        //获取渠道商支持的支付渠道
        // getPayWayByChannel(channelId);
      }
       
    };

    
  function getAppsPayWays(){
      // 查询商户的APP
      var companyId = $("#companyId").val();
      
      if(isChange == 0){
        return;
      }else{
        $("#appId").empty();
        $("#appId").append('<option value="">全部</option>');
        $("#rateId").empty();
        $("#rateId").append('<option value="">全部</option>');
        $.ajax({
          type:"get",
          url:"${basePath}/Payv2BussiManagerAlldata/getApps.do?companyId="+companyId,
          async:true,
          success:function(data){
            if(!!data&&data.resultCode==200){
              var list = data.Data,
              str="";
                var length = list.length;
              for(var i=0;i<length;i++){
                str+='<option value="'+list[i].id+'">'+list[i].appName+'</option>';
              }
              $("#appId").append(str);
              $(".choose .searchable-select").remove();
              $('#appId').searchableSelect();
            }else{
              alert(data.message);
            }
          }
        });
      }
       // 查询商户的支付渠道
        if(companyId ==null || companyId == ""){
          $("#rateId").empty();
          $("#rateId").append('<option value="">全部</option>');
          $.ajax({
            type:"get",
            url:"${basePath}/Payv2PayOrder/getRateList.do",
            async:true,
            success:function(data){
              if(!!data&&data.resultCode==200){
                var list = data.Data,
                  str="";
                  var length = list.length;
                for(var i=0;i<length;i++){
                  str+='<option value="'+list[i].id+'">'+list[i].rateName+'</option>';
                }
                $("#rateId").append(str);
                $(".choosePayWayRate .searchable-select").remove();
                $('#rateId').searchableSelect();
              }else{
                alert(data.message);
              }
            }
          });
        }else{
          $("#rateId").empty();
          $("#rateId").append('<option value="">全部</option>');
          $.ajax({
            type:"get",
            url:"${basePath}/Payv2BussiManagerAlldata/getPayWays.do?companyId="+companyId,
            async:true,
            success:function(data){
              if(!!data&&data.resultCode==200){
                var list = data.Data,
                  str="";
                  var length = list.length;
                for(var i=0;i<length;i++){
                  str+='<option value="'+list[i].id+'">'+list[i].rateName+'</option>';
                }
                $("#rateId").append(str);
                $(".choosePayWayRate .searchable-select").remove();
                $('#rateId').searchableSelect();
              }else{
                alert(data.message);
              }
            }
          }); 
        }    

    };
    // //查询渠道商的支付渠道
    // function getPayWayByChannel(channelId){
    //   $.ajax({
    //         type:"get",
    //         url:"${basePath}/Payv2BussiManagerAlldata/getPayWaysByChannel.do?channelId="+channelId,
    //         async:true,
    //         success:function(data){
    //           if(!!data&&data.resultCode==200){
    //             var list = data.Data,
    //               str="";
    //               var length = list.length;
    //             for(var i=0;i<length;i++){
    //               str+='<option value="'+list[i].id+'">'+list[i].rateName+'</option>';
    //             }
    //             $("#rateId").append(str);
    //             $(".choosePayWayRate .searchable-select").remove();
    //             $('#rateId').searchableSelect();
    //           }else{
    //             alert(data.message);
    //           }
    //         }
    //       }); 
    // }
    //获取支付平台下的支付渠道
    function getPayWayList(){
        if(isChange == 0 || $("#companyId").val() != ""){
          return;
        }else{
          var payWayId = $("#payWayId").val();
          $("#rateId").empty();
          $("#rateId").append('<option value="">全部</option>');
          $.ajax({
              type:"get",
              url:"${basePath}/Payv2PayOrder/getRateList.do?payWayId="+payWayId,
              async:true,
              success:function(data){
                if(!!data&&data.resultCode==200){
                  var list = data.Data,
                    str="";
                    var length = list.length;
                  for(var i=0;i<length;i++){
                    str+='<option value="'+list[i].id+'">'+list[i].rateName+'</option>';
                  }
                  $("#rateId").append(str);
                  $(".choosePayWayRate .searchable-select").remove();
                  $('#rateId').searchableSelect();
                }else{
                  alert(data.message);
                }
              }
          });
        } 
      }
      $(document).keypress(function(e) {			
		   	// 回车键事件  
		      if(e.which == 13) {  
		  		jQuery(".confirmButton").click();
		  		if($(".data1").val() != "" && $(".data2").val() != "") {
				$(".tabChange .count").removeClass("actives");
					cdata.dateType = 5;
					
					cdata.startTime = $(".data1").val();
					cdata.endTime = $(".data2").val();
				}
				cdata.channelId = $("#channelId").val();
				cdata.companyId = $("#companyId").val();	
				cdata.appId = $("#appId").val();
				cdata.payWayId = $("#payWayId").val();
				cdata.rateId = $("#rateId").val();
				curxdata();	
				charts();
		      }  
		});

</script>

</html>
